<!--
 * @Author: yangzr 1076420747@qq.com
 * @Date: 2022-08-26 17:57:04
 * @LastEditors: yangzr 1076420747@qq.com
 * @LastEditTime: 2023-05-18 16:26:05
 * @FilePath: \ktgj-crm\src\views\finance\autoBillResult.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
  <template>
  <div class="autoBillAdjust">
    <el-form
        :model="results"
        :inline="true"
        size="mini"
        ref="ruleForm"
        label-width="100px">
      <el-form-item label="账单生成时间">
      <el-date-picker value-format="yyyy-MM-dd"
       v-model="results.billDateForward"
      type="date"
      placeholder="选择日期">
    </el-date-picker>
      </el-form-item>
       <!-- <el-form-item label="账单结束时间">
         <el-date-picker
         value-format="yyyy-MM-dd"
         v-model="results.billDateBack"
         type="date"
         placeholder="选择日期">
    </el-date-picker> 
      </el-form-item> -->
        <el-form-item label="账单号">
          <el-input v-model="results.billnumber"></el-input>
        </el-form-item>
        <!-- <el-form-item label="出票渠道">
          <el-select v-model="results.typeoferror">
            <el-option
              :label="item.names"
              v-for="(item, index) in type"
              :key="index"
              :value="item.id"
            ></el-option>
          </el-select>
          </el-form-item>
          <el-form-item label="出票途径">
          <el-select v-model="results.Approach">
            <el-option
              :label="item.names"
              v-for="(item, index) in channels"
              :key="index"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item> -->
            <el-form-item label="渠道类型">
        <el-select clearable v-model="results.typeoferror" @change="changeexceltype">
          <el-option
            :label="item.names"
            v-for="(item, index) in type"
            :key="index"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="报表渠道">
        <el-select clearable v-model="results.Approach">
          <div v-if="this.changeexceltypeList == 'airline'">
            <el-option
              :label="item.airlinerShorter"
              v-for="(item, index) in airlinerList"
              :key="index"
              :value="item.id"
            ></el-option>
          </div>
          <div v-if="this.changeexceltypeList == 'ticketingPlatform'">
            <el-option
              :label="item.name"
              v-for="(item, index) in reporttype"
              :key="index"
              :value="item.name"
            ></el-option>
          </div>
          <div v-if="this.changeexceltypeList == 'paymentPlatform'">
            <el-option
              :label="item.names"
              v-for="(item, index) in channels"
              :key="index"
              :value="item.id"
            ></el-option>
          </div>
        </el-select>
      </el-form-item>
        <el-form-item label="客票状态" prop="date1">
          <el-select clearable v-model="results.ticketStart">
            <el-option
              :label="item.names"
              v-for="(item, index) in ticketStatus"
              :key="index"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="票号">
          <el-input v-model="results.ticketNumber"></el-input>
        </el-form-item>
        <el-form-item label="对账结果" prop="date1">
          <el-select clearable v-model="results.reconciliation">
            <el-option
              :label="item.names"
              v-for="(item, index) in checkResults"
              :key="index"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="订单号">
          <el-input v-model="results.orderId"></el-input>
        </el-form-item> -->
        <!-- <el-form-item label="循环次数">
            <el-radio-group v-model="results.num">
              <el-radio label="0">全部</el-radio>
              <el-radio label="1">不超出</el-radio>
              <el-radio label="2">超出</el-radio>
            </el-radio-group>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="viewBillDetails"
            >查询</el-button
          >
          <!-- <el-button type="primary" @click="batchsubmit"
            >批量提交</el-button
          > -->
        </el-form-item>
      </el-form>
      <el-table :data="tableData" border class="account_table" size="mini"
      :header-cell-style="{ color: '#fff', background: '#6090EC', fontSize: '11px', fontWeight: 'normal'}"  >
        <el-table-column  prop="ticketingChannel" label="报表渠道" width="100"></el-table-column>
        <el-table-column prop="billExceptionId" label="账单号" width="120"></el-table-column>
        <el-table-column prop="outsideBillNumber" label="外部单号" width="120"></el-table-column>
        <el-table-column prop="dataStart" label="客票类型" width="120"></el-table-column>
        <el-table-column prop="createTime" label="账单生成时间"  width="160" ></el-table-column>
        <el-table-column prop="exceptionType" label="对账结果" width="120"> </el-table-column>
         <el-table-column prop="amount" label="总金额" width="120"> </el-table-column>
          <el-table-column prop="taxAmount" label="税费" width="120"> </el-table-column>
           <el-table-column prop="commission" label="佣金" width="120"> </el-table-column>
           <el-table-column prop="billTimeNumber" label="账单号" width="120"> </el-table-column>
        <el-table-column prop="status" label="状态" width="120"> </el-table-column>
        <!-- <el-table-column prop="exceptionType" label="对账结果" width="120">
           <template slot-scope="scope">
                    <template v-if="scope.row.contactInformationType=='normal'">正常</template>
                    <template v-if="scope.row.contactInformationType=='buyMoneyLess'">少收客人票价</template>
                    <template v-if="scope.row.contactInformationType=='buyMoneyMore'">多收客人票价</template>
                    <template v-if="scope.row.contactInformationType=='returnMoneyLess'">少收客人退票费</template>
                    <template v-if="scope.row.contactInformationType=='returnMoneyMore'">多收客人退票费</template>
                    <template v-if="scope.row.contactInformationType=='duplicateTicketNumber'">票号重复</template>
                    <template v-if="scope.row.contactInformationType=='crmLess'">CRM有对方没有</template>
                    <template v-if="scope.row.contactInformationType=='crmMore'">CRM没有对方有</template>
           </template>
        </el-table-column> -->
        <el-table-column prop="checkTimes" label="对账次数" width="120"> </el-table-column>
         <el-table-column prop="ticketNumber" label="票号" width="120"> </el-table-column>
        <!-- <el-table-column prop="right" label="操作" width="200">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)"  size="small"
              >查看</el-button
            >
            <el-button  size="small">对账结果</el-button>
          </template>
        </el-table-column> -->
         <el-table-column prop="right" label="修改" width="200">
          <template slot-scope="scope">
            <el-popconfirm title="是否修改为票号重复？" @confirm="modifybanksrepeat">
           <el-button slot="reference" size="small" @click="banksrepeat(scope.row)">修改为票号重复</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 15, 20]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageTotal"
        >
        </el-pagination>
      </div>
  </div>
</template>

<script>
export default {
  name:'autoBillAdjust',
  components:{

  },
  data() {
    return {
      ticketid:"",
      // 报表支付渠道
      channels: [
        {
          id: "",
          names: "全部",
        },
        {
          id: '1',
          names: "汇付天下",
        },
        {
          id: '2',
          names: "支付宝",
        },
        {
          id: '3',
          names: "易宝出票",
        },
        {
          id: 4,
          names: "易生",
        },
      ],
       // 报表类型
      reporttype: [
        {
          name: "汇付天下",
        },
        {
          name: "航协出票",
        },
      
        {
          name: "中航信平台",
        },
      
        {
          name: "其他",
        },
        {
          name: "易宝支付",
        },
       
      
        {
          name: "德付通",
        },
       
        {
          name: "携程",
        },
      
        {
          name: "易宝出票",
        },
        {
          name: "人工出票",
        },
        {
          name: "瑞丽",
        },
        {
          name: "华夏",
        },
        {
          name: "航班管家",
        },
      ],
       // 航空公司
      airlinerList: [],
      changeexceltypeList: "",
      pageSize: 10,
      currentPage: 1,
      pageTotal: 0,
      results:{
        billDateForward:"",
        billDateBack:"",
        billnumber:'',
        typeoferror:"",
        ticketStart:"",
        ticketNumber: "",
        reconciliation:"",
        value1:'',
        startTime:'',
        endTime:'',
        Approach:"",
        orderId:'',
        num:"",
      },
      tableData: [{
        a:''
      }],
      type: [
        {
          id: 'airline',
          names: "航司",
        },
        {
          id: 'ticketingPlatform',
          names: "出票平台",
        },
        {
          id: 'paymentPlatform',
          names: "支付平台",
        },
      ],
      // 客票状态
      ticketStatus:[
        {
          id: 0,
          names: "全部",
        },
        {
          id: 1,
          names: "未知",
        },
        {
          id: 2,
          names: "销售",
        },
        {
          id: 3,
          names: "退票",
        },
        {
          id: 4,
          names: "取消订单",
        },
      ],
      checkResults:[
        {
          id: 'normal',
          names: "正常",
        },
        {
          id: 'buyMoneyLess',
          names: "少收客人票价",
        },
        {
          id: 'buyMoneyMore',
          names: "多收客人票价",
        },
        {
          id: 'returnMoneyLess',
          names: "少收客人退票费",
        },
        {
          id: 'returnMoneyMore',
          names: "多收客人退票费",
        },
        {
          id: 'duplicateTicketNumber',
          names: "票号重复",
        },
        
        {
          id: 'crmLess',
          names: "CRM有对方没有",
        },
        {
          id: 'crmMore',
          names: "CRM没有对方有",
        },
      ],
       // 出票途径
      channels: [
        {
          id: 0,
          names: "全部",
        },
        {
          id: 1,
          names: "汇付天下",
        },
        {
          id: 2,
          names: "支付宝",
        },
        {
          id: 3,
          names: "易宝出票",
        },
        {
          id: 4,
          names: "易生",
        },
      ],
    }
  },
  methods:{
    // 修改为票号重复
    modifybanksrepeat(){
        this.$axios.getticketNumRepeat({
          id:this.ticketid
      }).then((res)=>{
        if(res.code=='200'){
        this.$message({
          message: '修改成功', 
          type: 'success'
        });
        this.getreconciliationAdjustment()
        }else{
          this.$message({
          message: '抱歉，修改失败',
          type: 'warning'
        });
        }
      })
    },
    // 修改票号重复
    banksrepeat(row){
      console.log(row)
      this.ticketid=row.billExceptionId
    },
    changeexceltype(row) {
      console.log(row);
      this.changeexceltypeList = row;
      console.log(this.changeexceltypeList);
    },
    // 表格数据
    getreconciliationAdjustment(){
      this.$axios.getreconciliationAdjustment({
        billNum:this.results.billnumber,
        billDateForward:this.results.billDateForward,
        billDateBack:this.results.billDateBack,
        ticketingChannel:this.results.Approach,
        ticketStart:this.results.ticketStart,
        ticketNum:this.results.ticketNumber,
        reconciliation:this.results.reconciliation,
      }).then(res=>{
        console.log(res)
        if(res.code=='200'){
          this.tableData=res.data
          this.pageTotal=res.total
        }
      })
    },
    // 查询按钮
    viewBillDetails(){
      localStorage.setItem("pageSize", 10);
        localStorage.setItem("pageNum", 1);
      this.getreconciliationAdjustment()
    },
    // 批量提交按钮
    batchsubmit(){},
    // 表格查看按钮
    handleClick(row){
      console.log(row)
    },
    // 分页
     handleSizeChange(value) {
      console.log("1", value);
      localStorage.setItem("pageSize", value);
      localStorage.setItem("pageNum", 1);
      this.getreconciliationAdjustment();
      this.pageSize = value;
    },
    handleCurrentChange(value) {
      console.log("2", value);
      localStorage.setItem("pageNum", value);
      localStorage.setItem("pageSize", this.pageSize);
      this.currentPage=value
      this.getreconciliationAdjustment();
      // orders = res.data;
    },
    // 航空公司
    getflightlist() {
      this.$axios.getflightlist({}).then((res) => {
        if (res.code == "200") {
          let list = JSON.parse(JSON.stringify(res.data));
          this.airlinerList = list.filter((item) => {
            if (item.airliner != null && item.airlinerShorter != null) {
              return item;
            } else {
            }
          });
          this.airlinerList.forEach((item) => {
            item.airlinerShorter = item.airlinerShorter + item.airlinerId;
            item.ids = String(item.id)
          });
          console.log(this.airlinerList);
        }
      });
    },
  },
  mounted() {
    // this.$router.go(0)
    // 表格数据
    this.getreconciliationAdjustment()
    this.getflightlist()
  }
}
</script>

<style scoped>
  .autoBillAdjust {
    margin: 20px;
  }
</style>